home *** CD-ROM | disk | FTP | other *** search
/ Champak 130 / Vol 130.iso / games / tom.swf / scripts / classes / game / Panel.as < prev    next >
Encoding:
Text File  |  2011-04-12  |  2.6 KB  |  101 lines

  1. package classes.game
  2. {
  3.    import flash.display.*;
  4.    import flash.events.*;
  5.    import flash.text.*;
  6.    import libs.kjc.*;
  7.    
  8.    [Embed(source="/_assets/assets.swf", symbol="classes.game.Panel")]
  9.    public class Panel extends MovieClip
  10.    {
  11.       
  12.       internal static var tom:MovieClip;
  13.        
  14.       
  15.       private var addFrm:Number;
  16.       
  17.       public var poseMc:MovieClip;
  18.       
  19.       private var spd:Number;
  20.       
  21.       private var mFrm:int;
  22.       
  23.       private var msAc:Boolean;
  24.       
  25.       private var id:int;
  26.       
  27.       private var cFrm:Number;
  28.       
  29.       public function Panel()
  30.       {
  31.          super();
  32.          this.gotoAndStop("Point");
  33.          mFrm = this.currentFrame;
  34.          cFrm = 1;
  35.          id = KJC_general.Random(2);
  36.          this.poseMc.gotoAndStop(1 + id);
  37.          msAc = true;
  38.          this.gotoAndStop(1);
  39.       }
  40.       
  41.       internal function setPanel(param1:Number, param2:Number) : void
  42.       {
  43.          addFrm = param1;
  44.          var _loc3_:Number = mFrm / addFrm;
  45.          spd = param2 / _loc3_;
  46.          this.play();
  47.          this.addEventListener(Event.ENTER_FRAME,checkHit);
  48.       }
  49.       
  50.       private function checkHit(param1:Event) : void
  51.       {
  52.          var _loc3_:Boolean = false;
  53.          cFrm += addFrm;
  54.          if(this.poseMc.m0.currentFrame == this.poseMc.m0.totalFrames)
  55.          {
  56.             this.poseMc.m0.gotoAndStop(1);
  57.             this.poseMc.m1.gotoAndStop(1);
  58.          }
  59.          else
  60.          {
  61.             this.poseMc.m0.nextFrame();
  62.             this.poseMc.m1.nextFrame();
  63.          }
  64.          var _loc2_:int = Math.round(cFrm);
  65.          if(_loc2_ > this.totalFrames)
  66.          {
  67.             _loc2_ = this.totalFrames;
  68.          }
  69.          this.gotoAndStop(_loc2_);
  70.          this.x += spd;
  71.          if(msAc == true)
  72.          {
  73.             _loc3_ = Boolean(tom.hit.hitTestObject(this.poseMc.hit));
  74.             if(_loc3_ == true)
  75.             {
  76.                msAc = false;
  77.                if(tom.id == id)
  78.                {
  79.                   Game(this.parent).missionSucces(id);
  80.                }
  81.                else
  82.                {
  83.                   tom.actionTom("FAIL");
  84.                }
  85.             }
  86.          }
  87.          if(this.currentFrame == this.totalFrames)
  88.          {
  89.             this.removeEventListener(Event.ENTER_FRAME,checkHit);
  90.             this.stop();
  91.             this.parent.removeChild(this);
  92.          }
  93.          else if(this.currentFrame >= mFrm && msAc == false)
  94.          {
  95.             msAc = false;
  96.             this.parent.setChildIndex(this,1);
  97.          }
  98.       }
  99.    }
  100. }
  101.